package com.cs.archivesmanagement.entity;

import javax.persistence.*;

/**
 * Created by amo on 2015/8/21.
 */
@Entity
@Table(name = "am_account", schema = "", catalog = "csam")
public class AmAccount {


    private int accountId;
    private String accountAc;
    private String accountContact;
    private Integer accountGender;
    private String accountNickname;
    private String accountPsw;
    private int accountWorkNum;
    private AmDepartment accountDepartment;
    private AmRole accountRole;


    public AmAccount(int id) {
        this.accountId = id;

    }

    public AmAccount() {

    }


    @Id
    @Column(name = "Account_id", nullable = false, insertable = true, updatable = true)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public int getAccountId() {
        return accountId;
    }

    public void setAccountId(int accountId) {
        this.accountId = accountId;
    }

    @Basic
    @Column(name = "Account_ac", nullable = true, insertable = true, updatable = true, length = 30)
    public String getAccountAc() {
        return accountAc;
    }

    public void setAccountAc(String accountAc) {
        this.accountAc = accountAc;
    }

    @Basic
    @Column(name = "Account_contact", nullable = true, insertable = true, updatable = true, length = 20)
    public String getAccountContact() {
        return accountContact;
    }

    public void setAccountContact(String accountContact) {
        this.accountContact = accountContact;
    }

    @Basic
    @Column(name = "Account_gender", nullable = true, insertable = true, updatable = true)
    public Integer getAccountGender() {
        return accountGender;
    }

    public void setAccountGender(Integer accountGender) {
        this.accountGender = accountGender;
    }

    @Basic
    @Column(name = "Account_nickname", nullable = true, insertable = true, updatable = true, length = 30)
    public String getAccountNickname() {
        return accountNickname;
    }

    public void setAccountNickname(String accountNickname) {
        this.accountNickname = accountNickname;
    }

    @Basic
    @Column(name = "Account_psw", nullable = true, insertable = true, updatable = true, length = 30)
    public String getAccountPsw() {
        return accountPsw;
    }

    public void setAccountPsw(String accountPsw) {
        this.accountPsw = accountPsw;
    }

    @Basic
    @Column(name = "Account_work_num", nullable = false, insertable = true, updatable = true)
    public int getAccountWorkNum() {
        return accountWorkNum;
    }

    public void setAccountWorkNum(int accountWorkNum) {
        this.accountWorkNum = accountWorkNum;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        AmAccount amAccount = (AmAccount) o;

        if (accountId != amAccount.accountId) return false;
        if (accountWorkNum != amAccount.accountWorkNum) return false;
        if (accountAc != null ? !accountAc.equals(amAccount.accountAc) : amAccount.accountAc != null) return false;
        if (accountContact != null ? !accountContact.equals(amAccount.accountContact) : amAccount.accountContact != null)
            return false;
        if (accountGender != null ? !accountGender.equals(amAccount.accountGender) : amAccount.accountGender != null)
            return false;
        if (accountNickname != null ? !accountNickname.equals(amAccount.accountNickname) : amAccount.accountNickname != null)
            return false;
        if (accountPsw != null ? !accountPsw.equals(amAccount.accountPsw) : amAccount.accountPsw != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = accountId;
        result = 31 * result + (accountAc != null ? accountAc.hashCode() : 0);
        result = 31 * result + (accountContact != null ? accountContact.hashCode() : 0);
        result = 31 * result + (accountGender != null ? accountGender.hashCode() : 0);
        result = 31 * result + (accountNickname != null ? accountNickname.hashCode() : 0);
        result = 31 * result + (accountPsw != null ? accountPsw.hashCode() : 0);
        result = 31 * result + accountWorkNum;
        return result;
    }

    @OneToOne
    @JoinColumn(name = "Account_department", referencedColumnName = "Department_id")
    public AmDepartment getAccountDepartment() {
        return accountDepartment;
    }

    public void setAccountDepartment(AmDepartment accountDepartment) {
        this.accountDepartment = accountDepartment;
    }

    @OneToOne
    @JoinColumn(name = "Account_role", referencedColumnName = "Role_id")
    public AmRole getAccountRole() {
        return accountRole;
    }

    public void setAccountRole(AmRole accountRole) {
        this.accountRole = accountRole;
    }
}
